package main

import (
	"fmt"
	"io"
	"net/http"
)

func main() {
	client := http.Client{}
	//func (c *Client) Get(url string) (resp *Response, err error) {
	res, err := client.Get("https://www.baidu.com")
	if err != nil {
		fmt.Println("client.Get err： ", err)
		return
	}

	//beego,gin ==> web框架
	ct := res.Header.Get("Content-Type")
	date := res.Header.Get("date")
	server := res.Header.Get("Server")

	fmt.Println("cotent-type", ct)
	fmt.Println("date:", date)
	fmt.Println("server: ", server)

	fmt.Println("request url: ", res.Request.URL)
	fmt.Println("code: ", res.StatusCode)
	fmt.Println("status: ", res.Status)

	body := res.Body
	fmt.Println("body : ", body)
	readBodyStr, err := io.ReadAll(body)
	if err != nil {
		fmt.Println("read body err: ", err)
		return
	}

	fmt.Println("body string: ", string(readBodyStr))
}
